﻿using System;
using Microsoft.AspNetCore.Mvc;
using studentSubsidy.Entity;
using studentSubsidy.Entity.Apply;
using studentSubsidy.Service;

namespace studentSubsidy.Controllers
{
    [ApiController]
    [Route("api/apply/[Action]")]
    public class ApplyController: Controller
    {
        private ApplyService _applyService= new ApplyService();
        
        [HttpPost(Name = "submit")]
        public Result Submit([FromBody] ApplyQuery applyQuery)
        {
            return _applyService.submitApply(applyQuery);
        }
        
        [HttpGet(Name = "getApplyWithoutCheck")]
        public Result GetApplyWithoutCheck([FromQuery] int user_id)
        {
            return _applyService.getApply(user_id);
        }
        
        [HttpPost(Name = "getApplyDetail")]
        public Result GetApplyDetail([FromBody]ApplyDetailQuery applyDetailQuery)
        {
            return _applyService.getApplyDetail(applyDetailQuery);
        }
        
        [HttpGet(Name = "getApplyDetailById")]
        public Result GetApplyDetailById([FromQuery] int applyId)
        {
            return _applyService.getApplyDetailById(applyId);
        }
        
        [HttpPost(Name = "getApplyFile")]
        public Result GetApplyFile([FromBody]ApplyDetailQuery applyDetailQuery)
        {
            return _applyService.getApplyFile(applyDetailQuery);
        }
        
        [HttpGet(Name = "getApplyFileById")]
        public Result GetApplyFileById([FromQuery]int applyId)
        {
            return _applyService.getApplyFileById(applyId);
        }
        
        [HttpPost(Name = "deleteApply")]
        public Result DeleteApply([FromBody]ApplyDetailQuery applyDetailQuery)
        {
            return _applyService.DeleteApply(applyDetailQuery);
        }
        
        [HttpPost(Name = "getAllApply")]
        public Result getAllApply([FromQuery]string role)
        {
            return _applyService.getAllApply(role);
        }

        [HttpGet(Name = "checkIsApply")]
        public Result CheckIsApply([FromQuery] int project_id,int user_id)
        {
            return _applyService.isHasApply(project_id, user_id);
        }

        [HttpGet(Name = "hasCheckList")]
        public Result HasCheckList([FromQuery] int user_id)
        {
            return _applyService.hasCheckList(user_id);
        }
        
        [HttpGet(Name = "getRejectList")]
        public Result GetRejectList([FromQuery] int user_id)
        {
            return _applyService.getRejectList(user_id);
        }
        
        [HttpGet(Name = "getNeedSignedList")]
        public Result GetNeedSignedList([FromQuery] int userId)
        {
            return _applyService.getNeedSignedList(userId);
        }
        
        [HttpGet(Name = "getHasSignedCheckList")]
        public Result GetHasSignedCheckList([FromQuery] int userId)
        {
            return _applyService.getHasSignedCheckList(userId);
        }
    }
}